﻿using System;
using _5E.Infrastructure.Collections;
using Melee.Contract;
using Melee.Controller.Request;
using Melee.Controller.Routing;
using Melee.DataContract.Messaging;

namespace Melee.Controller.Handlers
{
    public class GetCityDetailHandler : RequestHandler
    {
        private ICityService m_cityService = null;

        public GetCityDetailHandler(ICityService cityService)
            : base(Routes.GET_CITY_DETAIL)
        {
            m_cityService = cityService;
        }

        public override void Handle(WebRequest webRequest)
        {
            Handle(webRequest, rq =>
            {
                GetCityDetailRequest request = new GetCityDetailRequest
                {
                    LoginId = rq.Cookie.LoginId,
                    CityId = rq.QueryArguments.ExtractFor<Int32>("id")
                };
                return m_cityService.GetDetailBy(request);
            }, rp => rp.City);
        }
    }
}
